#include <iostream>
#include <algorithm>
#include<vector>
#include <cstring>
using namespace std;
class Solution {
public:
    const int INF = 1e8;
    bool dfs(vector<int>& nums, int i, int N, int dir) {
        // 遇到不符合条件的点，返回false
        if (nums[i] == 0) return false;
        // 遇到在考察中的点，说明形成了闭环，返回true
        if (nums[i] == INF) return true;
        int ndir = nums[i] > 0 ? 1 : -1;
        if (ndir == dir) {
            int j = (N + (nums[i] + i) % N) % N;
            // 将i处的值设为INF，标志i点在考察中
            nums[i] = INF;
            if (j != i && dfs(nums, j, N, dir)) {
                return true;
            } else {
                // i点不符合条件，赋值为0
                nums[i] = 0;
                return false;
            }
        }
        return false;
    }

    bool circularArrayLoop(vector<int>& nums) {
        int N = nums.size();
        for (int i = 0; i < N; ++i) {
            if (nums[i] == 0) continue;
            int dir = nums[i] > 0 ? 1 : -1;
            if (dfs(nums, i, N, dir)) {
                return true;
            }
        }
        return false;
    }
};

vector<string> split(const string& str, const string& delim) {  
    vector<string> res;  
    if("" == str) return res;  
    //先将要切割的字符串从string类型转换为char*类型  
    char * strs = new char[str.length() + 1] ; //不要忘了  
    strcpy(strs, str.c_str());   

    char * d = new char[delim.length() + 1];  
    strcpy(d, delim.c_str());  

    char *p = strtok(strs, d);  
    while(p) {  
        string s = p; //分割得到的字符串转换为string类型  
        res.push_back(s); //存入结果数组  
        p = strtok(NULL, d);  
    }   
    return res;  
}  
std::string& trim(std::string &s,string b) 
{
    if (s.empty()) 
    {
        return s;
    }
    s.erase(0,s.find_first_not_of(b));
    s.erase(s.find_last_not_of(b) + 1);
    return s;
}
int main(){
   try{
    Solution s;
    string ss;
    cin >>ss;
    ss=trim(ss," ");
    ss.erase(0,ss.find_first_not_of("["));
    ss.erase(0,ss.find_first_not_of("]"));
    auto v=split(ss,",");
    vector<int> vv;
    for(int i=0;i<v.size();i++){
        vv.push_back(stoi(v[i]));
    }

    if(s.circularArrayLoop(vv)){
        cout << "true"<<endl;
    }else{
        cout << "false" <<endl;
    }
    }catch(exception e){
        cout << "false" <<endl;
    }
    return 0;
}